void copy_16bit_code(void* code_start, void* code_end, u16int segment);
isr_stack go_v86(u16int cs, u16int ip, general_registers input);
void stop_signal(isr_stack* state);
void store_kernel_esp(u32int location);

bool v86_monitor(isr_stack* stack);
u8int get_instruction(isr_stack* state, u32int* prefixes);

bool v86_handle_intn(isr_stack* state);
bool v86_handle_iret(isr_stack* state, u32int prefixes);
bool v86_handle_pushf(isr_stack* state, u32int prefixes);
bool v86_handle_popf(isr_stack* state, u32int prefixes);
bool v86_handle_sti(isr_stack* state);
bool v86_handle_cli(isr_stack* state);
bool v86_handle_outdxal(isr_stack* state);
bool v86_handle_outdxax(isr_stack* state);
bool v86_handle_indxal(isr_stack* state);
bool v86_handle_indxax(isr_stack* state);

u32int v86_fetchip(isr_stack* state);
void v86_push16(isr_stack* state, u32int value);
u32int v86_pop16(isr_stack* state);
void v86_push32(isr_stack* state, u32int value);
u32int v86_pop32(isr_stack* state);
u32int pair_to_linear(u32int seg, u32int off);
u16int peekb(u32int seg, u32int off);
u16int peekw(u32int seg, u32int off);
u32int peekl(u32int seg, u32int off);
void pokeb(u32int seg, u32int off, u8int val);
void pokew(u32int seg, u32int off, u16int val);
void pokel(u32int seg, u32int off, u32int val);

static isr_stack v86_return;
static u32int kernel_esp;

extern void make_v86_jump(general_registers input, iret_image jump_data);
extern void end_v86_jump(u32int kernel_esp);

